package com.pricl.api.common.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pricl.biz.common.entity.ProvinceVO;
import com.pricl.biz.common.service.CommonService;
import com.pricl.biz.tag.entity.TagInfo;
import com.pricl.frame.core.R;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;

/**
 * 公共工具接口
 * @author winton
 *
 */
@Api(value="/api/common",description="公共接口")
@Controller
@RequestMapping("/api/common")
public class CommonApiController {
	
	@Autowired
	private CommonService commonService;
	
	/**
	 * 查询省份城市接口
	 * @return
	 */
	@ApiOperation(value = "查询城市", notes = "查询城市",consumes="application/x-www-form-urlencoded", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_VALUE,response=ProvinceVO.class)
	@RequestMapping(value="city",method=RequestMethod.GET)
	@ResponseBody
	public R getProvinceCity(@ApiParam(value="是否查询省份内的城市",required=false) @RequestParam(required=false) Boolean hasCity) {
		List<ProvinceVO> provinces = commonService.getProviceCity(hasCity);
		return R.ok(200,provinces,"获取城市成功");
	}
	
	/**
	 * 查询标签公共接口
	 * @return
	 */
	@ApiOperation(value = "查询标签公共接口", notes = "查询标签公共接口",consumes="application/x-www-form-urlencoded", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_VALUE,response=TagInfo.class)
	@RequestMapping(value="tag",method=RequestMethod.GET)
	@ResponseBody
	public R getTag() {
		List<TagInfo> tags = commonService.getTag();
		return R.ok(200,tags,"获取城市成功");
	}
	
	
}
